package cn.stylefeng.guns.modular.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.entity.IdjActivityApply;
import cn.stylefeng.guns.modular.entity.IdjBanner;
import cn.stylefeng.guns.modular.mapper.IdjBannerMapper;
import cn.stylefeng.guns.modular.service.IIdjBannerService;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 轮播图 服务实现类
 * </p>
 *
 * @author TANGWJ
 * @since 2020-07-30
 */
@Service
public class IdjBannerServiceImpl extends ServiceImpl<IdjBannerMapper, IdjBanner> implements IIdjBannerService {

	@Autowired
	private IdjBannerMapper mapper;
	
	@Override
	public LayuiPageInfo getList(Page<IdjActivityApply> page, Integer bannerType) {
		Page<Map<String,Object>> list = mapper.getList(page, bannerType);
		return LayuiPageFactory.createPageInfo(list);
	}

	@Override
	public ModelAndView edit(Long bannerId) {
		IdjBanner banner = mapper.selectByKeyId(bannerId);
		ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("banner", banner);
        return modelAndView;
	}

	@Override
	public int setStatus(IdjBanner banner) {
		return mapper.setStatus(banner);
	}

	@Override
	public int insert(IdjBanner banner) {
		return mapper.insert(banner);
	}

	@Override
	public int delete(Long bannerId) {
		return mapper.delete(bannerId);
	}

}
